package com.beerandjesus.sportofkings.handicapper.strategy.brisnet.singlefile;

import java.math.BigDecimal;

import org.apache.commons.lang.StringUtils;

import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.Workout;
import com.beerandjesus.sportofkings.handicapper.strategy.RacingCalculator;

public class FastWorkoutResolver {
	
	private RacingCalculator calc = new RacingCalculator();
	
	public boolean isSharpWorkout(Workout w) {
		String d = w.getDistance();
		String t = w.getTime();
		if (StringUtils.isEmpty(d) || StringUtils.isEmpty(t)) {
			return false;
		}
		// negative if a "bullet" work, we don't particularly care
		Float f = new BigDecimal(t).abs().floatValue();
		String dist;
		try {
			dist = calc.distanceFromYards(d);
		} catch (Exception e) {
			return false;
		}
		if (dist.equals("4 Furlongs") && f.compareTo(new Float(48.0)) < 0) {
			return true;
		}
		if (dist.equals("5 Furlongs") && f.compareTo(new Float(60.0)) < 0) {
			return true;
		}
		if (dist.equals("6 Furlongs") && f.compareTo(new Float(73.0)) < 0) {
			return true;
		}
		if (dist.equals("7 Furlongs") && f.compareTo(new Float(87.0)) < 0) {
			return true;
		}
		return false;
	}

}
